<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用户列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                           <!-- <li class="hidden">
                                <label>删除状态：</label>
                                <input type="text" name="deleted"/>
                            </li>
                            <li>
                                <label>用户名：</label>
                                <input type="text" name="username"/>
                            </li>-->
                            <li>
                                <label>昵称：</label>
                                <input type="text" name="nickname"/>
                            </li>
                            <li>
                                <label>真实姓名：</label>
                                <input type="text" name="realname"/>
                            </li>
                            <!--<li>
                                <label>推荐人昵称：</label>
                                <input type="text" name="tuiNickname"/>
                            </li>
                            <li>
                                <label>推荐人姓名：</label>
                                <input type="text" name="tuiRealname"/>
                            </li>-->
                            <li>
                                <label>所在门店：</label>
                                <input type="text" name="deptName"/>
                            </li>
                            <li>
                                <label>手机号：</label>
                                <input type="text" name="mobile"/>
                            </li>

                            <li>
                                <label>状态：</label>
                                <select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>会员类型：</label>
                                <select name="userType" th:with="type=${@dict.getType('web_user_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <!--<a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="system:webUser:add">
                    <i class="fa fa-plus"></i> 添加
                </a>-->
                <a class="btn btn-primary single disabled" onclick="$.operate.editTab()" shiro:hasPermission="system:webUser:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <!--<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:webUser:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:webUser:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var userType = "[[${userType}]]";
        var editFlag = [[${@permission.hasPermi('system:webUser:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:webUser:remove')}]];
        var userTypeDatas = [[${@dict.getType('web_user_type')}]];
        var statusDatas = [[${@dict.getType('sys_normal_disable')}]];
        var authStatusDatas = [[${@dict.getType('auth_status')}]];
        var web_user_type = [[${@dict.getType('web_user_type')}]];
        var prefix = ctx + "system/webUser";

        $(function() {
            var buttonType = [[${buttonType}]];
            if(buttonType ==null){
                buttonType ={checkbox: true};
            }else{
                buttonType ={radio: true};
            }
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/edit/-1",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                sortName: "createTime",
                sortOrder: "desc",
                modalName: "用户",
                columns: [
                    buttonType,
                {
                    field: 'id',
                    title: 'ID',
                    visible: true
                },
                {
                    field: 'nickname',
                    title: '昵称'
                },
                {
                    field: 'realname',
                    title: '真实姓名',
                    sortable: true
                },
                {
                    field: 'mobile',
                    title: '手机号',
                    sortable: true
                },
                {
                    field: 'sex',
                    title: '性别'
                },
                {
                    field: 'deptName',
                    title: '所在门店',
                    sortable: true
                },
                {
                    field: 'recycleType',
                    title: '服务项目',
                    sortable: true
                },
                {
                    field: 'tuiNickname',
                    title: '推荐人',
                    formatter: function(value, row, index) {
                       return value+"-"+row.tuiRealname
                    }
                },
<!--                {-->
<!--                    field: 'tuiRealname',-->
<!--                    title: '推荐人姓名'-->
<!--                },-->
<!--                {-->
<!--                    field: 'parentTime',-->
<!--                    title: '推荐时间',-->
<!--                    sortable: true-->
<!--                },-->
                {
                    field: 'status',
                    title: '状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(statusDatas, value);
                    },
                    sortable: true
                },
<!--                {-->
<!--                    field: 'earnings',-->
<!--                    title: '总收益',-->
<!--                    formatter: function(value, row, index) {-->
<!--                       return (value/100);-->
<!--                    },-->
<!--                    sortable: true-->
<!--                },-->
<!--                {-->
<!--                    field: 'score',-->
<!--                    title: '总积分',-->
<!--                    sortable: true-->

<!--                },-->
                {
                    field: 'headPic',
                    title: '头像',
                    formatter: function (value, row, index) {
                        var fileUrl = row.headPic;
                        if (fileUrl) {
                            var fileUrls = fileUrl.split(",");
                            for (var i = 0; i < fileUrls.length; i++) {
                                if (i == 0) {
                                    return $.table.imageView(fileUrls[i]);
                                }
                            }
                        }
                    },
                },
                {
                    field: 'realAuth',
                    title: '认证状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(authStatusDatas, value);
                    },
                    sortable: true
                },
                {
                    field: 'userType',
                    title: '会员类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(web_user_type, value);
                    },
                    sortable: true
                },
                {
                    field: 'lastLoginDate',
                    title: '最后登录时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        //actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function submitHandler(index, layero) {
			//var data = $("#" + table.options.id).bootstrapTable('getSelections'); //获取选中行
			var userId = $.table.selectFirstColumns(); //获取选中行的收列值
			if (userId == "") {
     			$.modal.alertWarning("请至少选择一条记录");
     			return;
     		}
     		// 父页面的变量
     		parent.zhipaiOrder(userId[0]);
			$.modal.close();
		}
    </script>
</body>
</html>